<?php

namespace App\Api;

use App\Http\Controllers\Controller;
use App\Models\Car;
use App\Models\Pet;
use App\Models\Used;
use Illuminate\Http\Request;
use App\Models\House;

class BigdataController extends Controller
{
    public function index()
    {
        $houses = House::all();
        $pets = Pet::all();
        $cars = Car::all();
        $useds = Used::all();
        return [
            'houses' => $houses,
            'pets' => $pets,
            'cars' => $cars,
            'useds' => $useds,
        ];
    }

    public function count()
    {
        $houseCount = House::all()->count();
        $petCount = Pet::all()->count();
        $carCount = Car::all()->count();
        $usedCount = Used::all()->count();
        return [
            ['name' => '房屋租售', 'count' => $houseCount],
            ['name' => '宠物', 'count' => $petCount],
            ['name' => '汽车', 'count' => $carCount],
            ['name' => '二手', 'count' => $usedCount],
        ];
    }
}
